package com.dk.service.impl;

import com.dk.mapper.SysAutoCodeRuleMapper;
import com.dk.pojo.SysAutoCodeRule;
import com.dk.pojo.SysAutoCodeRuleExample;
import com.dk.service.RuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RuleServiceimpl implements RuleService {

    @Autowired
    private SysAutoCodeRuleMapper codeRuleMapper;

    @Override
    public void insertcoderule(SysAutoCodeRule rule) {
        codeRuleMapper.insert(rule);
    }

    @Override
    public List<SysAutoCodeRule> getcoderule() {
        return codeRuleMapper.selectByExample(null);
    }

    @Override
    public void deleteByRuleId(Long ruleId) {
        codeRuleMapper.deleteByPrimaryKey(ruleId);
    }

    @Override
    public void deleteAllRuleId(List<String> ruleIds) {
        codeRuleMapper.deleteAllRuleId(ruleIds);
    }

    @Override
    public void updateRule(SysAutoCodeRule rule) {
        codeRuleMapper.updateByPrimaryKeySelective(rule);
    }

    @Override
    public List<SysAutoCodeRule> selectByExample(String codename) {
        SysAutoCodeRuleExample example=new SysAutoCodeRuleExample();
        example.createCriteria().andRuleCodeEqualTo(codename);
        List<SysAutoCodeRule> sysAutoCodeRules = codeRuleMapper.selectByExample(example);
        return sysAutoCodeRules;
    }
}
